package com.itheima.controller;

import com.itheima.pojo.JobOption;
import com.itheima.pojo.PageResult;
import com.itheima.pojo.Result;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
public class ReportController {
    @Autowired
    private ReportService reportService;

    @GetMapping("/report/empJobData")
    public Result getEmpJobData(){
        log.info("统计员工职位人数");
        JobOption jobOption = reportService.getEmpJobData();
        return Result.success(jobOption);
    }

    @GetMapping("/report/empGenderData")
    public Result getEmpGenderData(){
        log.info("统计员工性别人数");
        List<Map> genderList = reportService.getEmpGenderData();
        return Result.success(genderList);
    }

    @GetMapping("/report/studentDegreeData")
    public Result getStudentDegreeData(){
        log.info("统计学生学历人数");
        List<Map> degreeList = reportService.getStudentDegreeData();
        return Result.success(degreeList);
    }

    @GetMapping("/report/studentCountData")
    public Result getStudentCountData(){
        log.info("统计每班学生人数");
        Map studentCountData = reportService.getStudentCountData();
        return Result.success(studentCountData);
    }

    @GetMapping("/log/page")
    public Result getLogPage(@RequestParam Integer page, Integer pageSize){
        log.info("分页查询操作日志");
        PageResult pageResult = reportService.getLogPage(page, pageSize);
        return Result.success(pageResult);
    }
}
